コード例 #1
0
if (!empty($categoryId)) {
    $categoryInfo = CourseCategoryManager::getCategory($categoryId);
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
$errorMsg = '';
if (!empty($action)) {
    if ($action == 'delete') {
        if (api_get_multiple_access_url()) {
            if (api_get_current_access_url_id() == 1 || isset($_configuration['enable_multiple_url_support_for_course_category']) && $_configuration['enable_multiple_url_support_for_course_category']) {
                CourseCategoryManager::deleteNode($categoryId);
                Display::addFlash(Display::return_message(get_lang('Deleted')));
                header('Location: ' . api_get_self() . '?category=' . Security::remove_XSS($category));
                exit;
            }
        } else {
            CourseCategoryManager::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 = CourseCategoryManager::addNode($_POST['code'], $_POST['name'], $_POST['auth_course_child'], $category);
            Display::addFlash(Display::return_message(get_lang('Created')));
        } else {
            $ret = CourseCategoryManager::editNode($_POST['code'], $_POST['name'], $_POST['auth_course_child'], $categoryId);
            Display::addFlash(Display::return_message(get_lang('Updated')));
        }
        if ($ret) {
            $action = '';
        } else {