<?php

require_once "../etc/koala.conf.php";
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$user = lms_steam::get_current_user();
if (!($steam_group = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["course"]))) {
    throw new Exception("Course not found: " . $_GET["course"]);
}
if (!$steam_group instanceof steam_group) {
    throw new Exception("Is not a group: " . $_GET["course"]);
}
if ((string) $steam_group->get_attribute("OBJ_TYPE") != "course") {
    throw new Exception("Is not a course: " . $_GET["course"]);
}
$course = new koala_group_course($steam_group);
$backlink = PATH_URL . SEMESTER_URL . "/" . $course->get_semester()->get_name() . "/" . $course->get_name() . "/";
$course->set_attribute("SEM_APP_ID", NULL);
$_SESSION["confirmation"] = gettext("Reserve list removed.");
header("Location: " . $backlink);
exit;
while (list($paul_id, $steam_group_name) = each($paul_course_ids)) {
    //get meta for this course
    $meta = $paul_meta_data_all[$steam_group_name];
    //query bookings
    $query = "SELECT * FROM " . PAUL_SYNC_TABLE_NAME . " WHERE course_id_paul = '" . $paul_id . "';";
    $info_mysql_requests++;
    $result = mysql_query($query);
    $bookings_mtr = array();
    while ($transaction = mysql_fetch_object($result)) {
        $bookings_mtr[] = $transaction->matrnr;
    }
    $meta["imported users"] = $bookings_mtr;
    //set meta data to server
    $steam_group = $cache_steam_groups[$steam_group_name];
    $course = new koala_group_course($steam_group);
    $course->set_attribute("PAUL_SYNC_META_DATA", $meta);
    echo "setting metedate to course: " . $course->get_name() . " " . var_dump($meta) . $newline;
}
echo "cleaning up caches";
timelog("empty_cache", TRUE);
paul_sync_log("PAUL_SYNC\tcleaning cache data\t", PAUL_SYNC_LOGLEVEL_DEBUG);
// Empty koaLA Caches
foreach ($cleancache_users as $id => $user) {
    $cache = get_cache_function($user->get_name());
    $cache->drop("lms_steam::user_get_groups", $user->get_name(), TRUE);
    $cache->drop("lms_steam::user_get_groups", $user->get_name(), FALSE);
    $cache->drop("lms_steam::user_get_groups", $user->get_name());
    $cache->drop("lms_steam::user_get_profile", $user->get_name());
    $cache->drop("lms_portal::get_menu_html", $user->get_name(), TRUE);
}
foreach ($cleancache_groups as $id => $group) {