|
|
|
@ -22,7 +22,7 @@ $parentInfo = []; |
|
|
|
|
if (!empty($categoryId)) { |
|
|
|
|
$categoryInfo = $parentInfo = CourseCategory::getCategoryById($categoryId); |
|
|
|
|
} |
|
|
|
|
$parentId = $parentInfo ? $parentInfo['id'] : null; |
|
|
|
|
$parentId = $parentInfo ? $parentInfo['parent_id'] : null; |
|
|
|
|
|
|
|
|
|
switch ($action) { |
|
|
|
|
case 'delete': |
|
|
|
@ -37,31 +37,38 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
if (!empty($categoryId)) { |
|
|
|
|
$categoryRepo->delete($categoryRepo->find($categoryId)); |
|
|
|
|
CourseCategory::reorganizeTreePos($parentId); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
|
|
|
|
} |
|
|
|
|
header('Location: '.api_get_self().'?category='.Security::remove_XSS($category)); |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
case 'export': |
|
|
|
|
$courses = CourseCategory::getCoursesInCategory($categoryId); |
|
|
|
|
if (!empty($courses)) { |
|
|
|
|
if ($courses && count($courses) > 0) { |
|
|
|
|
$name = api_get_local_time().'_'.$categoryInfo['code']; |
|
|
|
|
$courseList = []; |
|
|
|
|
|
|
|
|
|
/* @var \Chamilo\CoreBundle\Entity\Course $course */ |
|
|
|
|
foreach ($courses as $course) { |
|
|
|
|
$courseList[] = $course->getTitle(); |
|
|
|
|
$courseList[] = [$course->getTitle()]; |
|
|
|
|
} |
|
|
|
|
Export::arrayToCsv($courseList, $name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
header('Location: '.api_get_self()); |
|
|
|
|
exit; |
|
|
|
|
$header = [get_lang('Course Title')]; |
|
|
|
|
Export::arrayToCsvSimple($courseList, $name, false, $header); |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('No courses found for this category'), 'warning')); |
|
|
|
|
header('Location: '.api_get_self().'?category='.Security::remove_XSS($categoryId)); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'moveUp': |
|
|
|
|
CourseCategory::moveNodeUp($categoryId, $_GET['tree_pos'], $category); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Update successful'))); |
|
|
|
|
if (CourseCategory::moveNodeUp($categoryId, $_GET['tree_pos'], $parentId)) { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Update successful'))); |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Cannot move category up'), 'error')); |
|
|
|
|
} |
|
|
|
|
header('Location: '.api_get_self().'?category='.Security::remove_XSS($category)); |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
case 'add': |
|
|
|
|
if (isset($_POST['formSent']) && $_POST['formSent']) { |
|
|
|
|
$categoryEntity = CourseCategory::add( |
|
|
|
@ -127,7 +134,7 @@ if ('add' === $action || 'edit' === $action) { |
|
|
|
|
|
|
|
|
|
$form_title = 'add' === $action ? get_lang('Add category') : get_lang('Edit this category'); |
|
|
|
|
if (!empty($categoryInfo)) { |
|
|
|
|
$form_title .= ' '.get_lang('Into').' '.$categoryInfo['name']; |
|
|
|
|
$form_title .= ' '.get_lang('Into').' '.$categoryInfo['title']; |
|
|
|
|
} |
|
|
|
|
$url = api_get_self().'?action='.Security::remove_XSS($action).'&id='.Security::remove_XSS($categoryId); |
|
|
|
|
$form = new FormValidator('course_category', 'post', $url); |
|
|
|
@ -223,7 +230,7 @@ if ('add' === $action || 'edit' === $action) { |
|
|
|
|
} |
|
|
|
|
echo Display::toolbarAction('categories', [$actions]); |
|
|
|
|
if (!empty($parentInfo)) { |
|
|
|
|
echo Display::page_subheader($parentInfo['name'].' ('.$parentInfo['code'].')'); |
|
|
|
|
echo Display::page_subheader($parentInfo['title'].' ('.$parentInfo['code'].')'); |
|
|
|
|
} |
|
|
|
|
echo CourseCategory::listCategories($categoryInfo); |
|
|
|
|
} |
|
|
|
|