2222
2323$ myCourseListAsCategory = api_get_configuration_value ('my_courses_list_as_category ' );
2424
25+ $ baseUrl = api_get_path (WEB_CODE_PATH ).'admin/course_category.php? '
26+ .http_build_query (['category ' => $ parentInfo ['code ' ] ?? '' ]);
27+
2528if (!empty ($ action )) {
2629 if ('export ' === $ action ) {
2730 $ categoryInfo = CourseCategory::getCategoryById ($ categoryId );
@@ -48,10 +51,10 @@ function ($value) {
4851 if ($ action === 'delete ' ) {
4952 CourseCategory::deleteNode ($ categoryId );
5053 Display::addFlash (Display::return_message (get_lang ('Deleted ' )));
51- header ('Location: ' .api_get_self (). ' ?category= ' .Security:: remove_XSS ( $ category ) );
54+ header ('Location: ' .$ baseUrl );
5255 exit ();
5356 } elseif (($ action === 'add ' || $ action === 'edit ' ) && isset ($ _POST ['formSent ' ]) && $ _POST ['formSent ' ]) {
54- $ newParentCategoryCode = $ _POST ['parent_id ' ] ?? $ category ;
57+ $ newParentCategoryCode = $ _POST ['parent_id ' ] ?? $ parentInfo [ ' code ' ] ?? '' ;
5558
5659 if ($ action === 'add ' ) {
5760 $ ret = CourseCategory::addNode (
@@ -69,7 +72,7 @@ function ($value) {
6972 $ _POST ['auth_course_child ' ],
7073 $ categoryId ,
7174 $ newParentCategoryCode ,
72- $ category
75+ $ parentInfo [ ' code ' ] ?? ''
7376 );
7477 $ categoryInfo = CourseCategory::getCategory ($ _POST ['code ' ]);
7578 $ ret = $ categoryInfo ['id ' ];
@@ -90,8 +93,8 @@ function ($value) {
9093 header ('Location: ' .api_get_path (WEB_CODE_PATH ).'admin/course_category.php ' );
9194 exit ;
9295 } 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 );
9598 Display::addFlash (Display::return_message (get_lang ('Updated ' )));
9699 exit ();
97100 }
@@ -137,15 +140,16 @@ function showCourses(button, categoryId) {
137140 echo '<div class="actions"> ' ;
138141 echo Display::url (
139142 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
141144 );
142145 echo '</div> ' ;
143146
144147 $ 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 ' ] ;
147150 }
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 )]);
149153 $ form = new FormValidator ('course_category ' , 'post ' , $ url );
150154 $ form ->addElement ('header ' , '' , $ form_title );
151155 $ form ->addElement ('hidden ' , 'formSent ' , 1 );
@@ -230,7 +234,7 @@ function showCourses(button, categoryId) {
230234 $ form ->setDefaults (
231235 [
232236 'auth_course_child ' => 'TRUE ' ,
233- 'parent_id ' => $ category ,
237+ 'parent_id ' => $ parentInfo [ ' code ' ] ?? '' ,
234238 ]
235239 );
236240 $ form ->addButtonCreate ($ text );
@@ -254,7 +258,7 @@ function showCourses(button, categoryId) {
254258 if (empty ($ parentInfo ) || $ parentInfo ['auth_cat_child ' ] === 'TRUE ' ) {
255259 $ newCategoryLink = Display::url (
256260 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'
258262 );
259263
260264 if (!empty ($ parentInfo ) && $ parentInfo ['access_url_id ' ] != $ urlId ) {
@@ -266,7 +270,7 @@ function showCourses(button, categoryId) {
266270 if (!empty ($ parentInfo )) {
267271 echo Display::page_subheader ($ parentInfo ['name ' ].' ( ' .$ parentInfo ['code ' ].') ' );
268272 }
269- echo CourseCategory::listCategories ($ category );
273+ echo CourseCategory::listCategories ($ parentInfo [ ' code ' ] ?? '' );
270274}
271275
272276Display::display_footer ();
0 commit comments