Ejemplo n.º 1
0
}
$categoryId = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null;
if (!empty($categoryId)) {
    $categoryInfo = CourseCategory::getCategory($categoryId);
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
$errorMsg = '';
if (!empty($action)) {
    if ($action == 'delete') {
        CourseCategory::deleteNode($categoryId);
        Display::addFlash(Display::return_message(get_lang('Deleted')));
        header('Location: ' . api_get_self() . '?category=' . Security::remove_XSS($category));
        exit;
    } elseif (($action == 'add' || $action == 'edit') && isset($_POST['formSent']) && $_POST['formSent']) {
        if ($action == 'add') {
            $ret = CourseCategory::addNode($_POST['code'], $_POST['name'], $_POST['auth_course_child'], $category);
            Display::addFlash(Display::return_message(get_lang('Created')));
        } else {
            $ret = CourseCategory::editNode($_POST['code'], $_POST['name'], $_POST['auth_course_child'], $categoryId);
            Display::addFlash(Display::return_message(get_lang('Updated')));
        }
        if ($ret) {
            $action = '';
        } else {
            $errorMsg = get_lang('CatCodeAlreadyUsed');
        }
    } elseif ($action == 'moveUp') {
        CourseCategory::moveNodeUp($categoryId, $_GET['tree_pos'], $category);
        header('Location: ' . api_get_self() . '?category=' . Security::remove_XSS($category));
        Display::addFlash(Display::return_message(get_lang('Updated')));
        exit;