Esempio n. 1
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //echo SEMESTER_URL;die;
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     $all_users = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), STEAM_ALL_USER);
     $scg = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), STEAM_COURSES_GROUP, CLASS_GROUP);
     $current_semester = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), $scg->get_groupname() . "." . STEAM_CURRENT_SEMESTER);
     if (!\lms_steam::is_steam_admin($user) && !lms_steam::is_semester_admin($current_semester, $user)) {
         include "bad_link.php";
         exit;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         $problems = "";
         $hints = "";
         if (empty($values["semester"])) {
             throw new Exception("Semester is not given.");
         }
         if (empty($values["id"])) {
             $problems .= gettext("The course ID is missing.") . " ";
             $hints .= gettext("The ID is necessary for unique identification, ordering and finding the course. Please fill this out.") . " ";
         }
         if (!empty($values["access"]) && $values["access"] == PERMISSION_COURSE_PASSWORD && empty($values["password"])) {
             $problems .= gettext("The course password is missing.") . " ";
             $hints .= gettext("You chose to password protect your course. Please provide a password.") . " ";
         }
         if (empty($problems) && !empty($values["get_lsf_infos"])) {
             // INFOS UEBER LSF HOLEN
             $lsf_client = new \hislsf_soap();
             unset($_SESSION["LSF_COURSE_INFO"]);
             // TODO: SEMESTER DYNAMISCH SETZEN
             $result = $lsf_client->get_available_courses(SYNC_HISLSF_SEMESTER, $values["id"]);
             if (isset($result->veranstaltung)) {
                 if (count($result->veranstaltung) == 1) {
                     header("Location: " . PATH_URL . "course/create" . "/" . $current_semester->get_name() . "/?lsf_course_id=" . $result->veranstaltung->Veranstaltungsschluessel);
                     exit;
                 } else {
                     header("Location: " . PATH_URL . "course" . "/" . $current_semester->get_name() . "/hislsf/" . $values["id"] . "/");
                     exit;
                 }
             } else {
                 $problems = "Keine Veranstaltungen im LSF unter dieser Nummer gefunden.";
             }
         }
         if (empty($problems)) {
             if (empty($values["name"])) {
                 $problems .= gettext("The course name is missing.") . " ";
                 $hints .= gettext("A name is necessary for identification.") . " ";
             }
             if (strpos($values['id'], '.')) {
                 $problems .= gettext("Please don't use the \".\"-char in the course ID.") . ' ';
             }
             if (empty($values["tutors"])) {
                 $values["tutors"] = "NN";
             }
             if (empty($problems)) {
                 if (!isset($values["hislsf"]) || !$values["hislsf"]) {
                     $values["lsf_id"] = "";
                 }
                 $max_members = -1;
                 if ($values["lsf_id"] === "") {
                     if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && preg_match('/[^-.0-9]/', trim($values["maxsize"]))) {
                         $problems .= gettext("Invalid max number of participants.") . " ";
                         $hints .= gettext("Please enter a valid number for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
                     } else {
                         if (!empty($values["maxsize"]) && trim($values["maxsize"]) != "" && trim($values["maxsize"]) < 0) {
                             $problems .= gettext("Invalid max number of participants.") . " ";
                             $hints .= gettext("Please enter a number equal or greater than '0' for the max number of participants.") . " " . gettext("Please note that the input of a '0' or to leave the field blank means no limitation.") . " ";
                         } else {
                             if (isset($values["maxsize"])) {
                                 if (trim($values["maxsize"]) === "") {
                                     $max_members = 0;
                                 } else {
                                     $max_members = (int) trim($values["maxsize"]);
                                 }
                             }
                         }
                     }
                 }
                 if (empty($problems)) {
                     try {
                         $new_course = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), $values["id"], $current_semester, FALSE, $values["name"]);
                     } catch (Exception $e) {
                         $problems .= gettext("The course ID already exists.") . " ";
                         $hints .= gettext("The ID is necessary for unique identification, ordering and finding the course. This ID already exists.") . " ";
                     }
                     if (empty($problems)) {
                         $new_course->set_attributes(array("OBJ_TYPE" => "course", "COURSE_PARTICIPANT_MNGMNT" => $obj_type, "COURSE_SEMESTER" => $values["semester"], "COURSE_TUTORS" => $values["tutors"], "COURSE_SHORT_DSC" => $values["short_dsc"], "COURSE_LONG_DSC" => $values["long_dsc"], "COURSE_HISLSF_ID" => $values["lsf_id"]));
                         $learners = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "learners", $new_course, FALSE, "Participants of course '" . $values["name"] . "'");
                         $learners->set_attribute("OBJ_TYPE", "course_learners");
                         $staff = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "staff", $new_course, FALSE, "Tutors of course '" . $values["name"] . "'");
                         $staff->set_attribute("OBJ_TYPE", "course_staff");
                         $staff->add_member($user);
                         $admins = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "admins", $new_course, FALSE, "Admins of course '" . $values["name"] . "'");
                         $admins->set_attribute("OBJ_TYPE", "course_admins");
                         // uncomment below if koala can handle admins vs tutors
                         //$admins->add_member( $user );
                         // RIGHTS MANAGEMENT =======================================
                         $course_calendar = $new_course->get_calendar();
                         $learners_workroom = $learners->get_workroom();
                         $course_workroom = $new_course->get_workroom();
                         $staff->set_sanction_all($staff);
                         $staff->sanction_meta(SANCTION_ALL, $staff);
                         $learners->set_sanction_all($staff);
                         $learners->sanction_meta(SANCTION_ALL, $staff);
                         $new_course->set_sanction_all($staff);
                         $new_course->sanction_meta(SANCTION_ALL, $staff);
                         $admins->set_sanction_all($admins);
                         $admins->sanction_meta(SANCTION_ALL, $admins);
                         $staff->set_sanction_all($admins);
                         $staff->sanction_meta(SANCTION_ALL, $admins);
                         $learners->set_sanction_all($admins);
                         $learners->sanction_meta(SANCTION_ALL, $admins);
                         $new_course->set_sanction_all($admins);
                         $new_course->sanction_meta(SANCTION_ALL, $admins);
                         $course_calendar->set_acquire(FALSE);
                         $course_calendar->set_sanction_all($staff);
                         $course_calendar->sanction_meta(SANCTION_ALL, $staff);
                         $course_calendar->set_sanction_all($admins);
                         $course_calendar->sanction_meta(SANCTION_ALL, $admins);
                         $course_calendar->set_read_access($learners, TRUE);
                         $course_calendar->set_write_access($new_course, FALSE);
                         $course_calendar->set_insert_access($new_course, FALSE);
                         $course_calendar->set_insert_access($all_users, FALSE);
                         // Course workroom
                         $course_workroom->set_sanction($new_course, SANCTION_READ | SANCTION_EXECUTE | SANCTION_ANNOTATE);
                         $course_workroom->set_sanction_all($staff);
                         $course_workroom->set_sanction_all($admins);
                         $course_workroom->sanction_meta(SANCTION_ALL, $staff);
                         $course_workroom->sanction_meta(SANCTION_ALL, $admins);
                         // Learners workroom
                         $learners_workroom->set_read_access($all_users, TRUE);
                         $learners_workroom->set_sanction($learners, SANCTION_READ | SANCTION_EXECUTE | SANCTION_ANNOTATE);
                         $learners_workroom->set_sanction_all($staff);
                         $learners_workroom->set_sanction_all($admins);
                         $learners_workroom->sanction_meta(SANCTION_ALL, $staff);
                         $learners_workroom->sanction_meta(SANCTION_ALL, $admins);
                         $koala_course = new \koala_group_course($new_course);
                         if (!isset($values["hislsf"]) || !$values["hislsf"]) {
                             $access = $values["access"];
                             $koala_course->set_access($access, $learners, $staff, $admins, KOALA_GROUP_ACCESS);
                             if (isset($values["password"]) && $access == PERMISSION_COURSE_PASSWORD) {
                                 $koala_course->get_group_learners()->set_password($values["password"]);
                             } else {
                                 $koala_course->get_group_learners()->set_password("");
                             }
                         } else {
                             $koala_course->set_access(PERMISSION_COURSE_HISLSF, $learners, $staff, $admins, KOALA_GROUP_ACCESS);
                         }
                         if ($max_members > -1) {
                             $learners->set_attribute(GROUP_MAXSIZE, $max_members);
                         }
                         // RIGHTS MANAGEMENT =======================================
                         // extensions:
                         if (isset($_POST["extensions_available"]) && !empty($_POST["extensions_available"])) {
                             $extensions_available = explode("/", $_POST["extensions_available"]);
                             if (isset($_POST["extensions_enabled"])) {
                                 $extensions_enabled = $_POST["extensions_enabled"];
                             } else {
                                 $extensions_enabled = array();
                             }
                             if (isset($_POST["extensions_enabled_add"])) {
                                 $extensions_enabled = array_merge($extensions_enabled, explode("/", $_POST["extensions_enabled_add"]));
                             }
                             if (is_array($extensions_available)) {
                                 foreach ($extensions_available as $extension_name) {
                                     $extension = \lms_steam::get_extensionmanager()->get_extension($extension_name);
                                     if (!is_object($extension)) {
                                         continue;
                                     }
                                     if (array_search($extension_name, $extensions_enabled) === FALSE) {
                                         $extension->disable_for($koala_course);
                                     } else {
                                         $extension->enable_for($koala_course);
                                     }
                                 }
                             }
                         }
                         $cache = get_cache_function("ORGANIZATION");
                         $cache->drop("lms_steam::semester_get_courses", $current_semester->get_id());
                         header("Location: " . PATH_URL . "semester/index" . "/" . $current_semester->get_name() . "/" . $new_course->get_name() . "/");
                         exit;
                     }
                 }
             }
         }
         if (!empty($problems)) {
             $frameResponseObject->setConfirmText($problems, $hints);
             //$portal->set_problem_description( $problems, $hints );
         }
     }
     if (!empty($_GET["lsf_course_id"])) {
         $lsf_client = new hislsf_soap();
         $course_infos = $lsf_client->get_course_information(SYNC_HISLSF_SEMESTER, $_GET["lsf_course_id"]);
         if (empty($course_infos) && empty($problems)) {
             $frameResponseObject->setConfirmText(gettext("Error getting course data from HIS/LSF."));
             //$portal->set_problem_description(gettext("Error getting course data from HIS/LSF.") );
         } else {
             if (empty($course_infos["course_dsc"])) {
                 $course_infos["course_dsc"] = "keine Beschreibung vorhanden.";
             } else {
                 $course_infos["course_dsc"] = unhtmlentities($course_infos["course_dsc"]);
             }
             $values = array("lsf_id" => $course_infos["course_lsf_id"], "id" => $course_infos["course_id"], "name" => $course_infos["course_name"], "tutors" => $course_infos["course_tutors"], "short_dsc" => $course_infos["course_type"], "long_dsc" => $course_infos["course_dsc"]);
         }
         $_SESSION["LSF_COURSE_INFO"] = "";
     }
     $content = \Course::getInstance()->loadTemplate("courses_create.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "courses_create.template.html" );
     $content->setVariable("FORM_ACTION", PATH_URL . "course/create" . "/" . $current_semester->get_name() . "/");
     $content->setVariable("VALUE_SEMESTER", h($current_semester->get_name()));
     //$content->setVariable( "INFO_TEXT", gettext( "Creating a course means..." ) );
     $content->setVariable("CONFIRMATION_TEXT", str_replace("%SEMESTER", h($current_semester->get_attribute("OBJ_DESC")), gettext("You are going to create a new course in <b>%SEMESTER</b>.")) . " " . gettext("Please fill out the requested meta data at first.") . " " . gettext("At the bottom, you can determine the manner of participant management.") . " " . gettext("Also you can add further course admins later on."));
     $content->setVariable("LABEL_GENERAL_INFORMATION", gettext("General Information"));
     $content->setVariable("LABEL_COURSE_ID", gettext("Course ID"));
     $content->setVariable("VALUE_COURSE_ID", isset($values) ? h($values["id"]) : '');
     $content->setVariable("LABEL_COURSE_NAME", gettext("Name"));
     $content->setVariable("VALUE_COURSE_NAME", isset($values) ? h($values["name"]) : '');
     $content->setVariable("LABEL_COURSE_SHORT_INFORMATION", gettext("Short Info"));
     $content->setVariable("VALUE_SHORT_DSC", isset($values) ? h($values["short_dsc"]) : '');
     $content->setVariable("SHORT_DSC_SHOW_UP", gettext("This value will show up in the semester's courses list beside id, name and staff members."));
     $content->setVariable("LABEL_COURSE_TUTORS", gettext("Staff members"));
     $content->setVariable("VALUE_TUTORS", isset($values) ? h($values["tutors"]) : '');
     $content->setVariable("LABEL_LONG_DSC", gettext("Long description"));
     $content->setVariable("LONG_DSC_SHOW_UP", gettext("This is for your course page. Please add information about schedule and locations at least."));
     $content->setVariable("VALUE_LONG_DSC", isset($values) ? h($values["long_dsc"]) : '');
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $content->setVariable("PARTICIPANT_MANAGEMENT", gettext("Participant Management"));
     if (isset($values) && $values["lsf_id"] > 1) {
         $content->setCurrentBlock("HIS_LSF_PM");
         $content->setVariable("LSF_COURSE_ID", isset($values) ? h($values["lsf_id"]) : '');
         $content->setVariable("LSF_COURSE", isset($values) ? h($values["id"]) : '' . " " . isset($values) ? h($values["name"]) : '' . " (" . isset($values) ? h($values["short_dsc"]) : '' . ")");
         if ($values["hislsf"]) {
             $content->setVariable("HISLSF_CHECKED", "CHECKED");
         }
         $content->setVariable("LABEL_HISLSF", "Ja, es soll die Teilnehmerverwaltung des HIS LSF verwendet werden.");
         $content->setVariable("HISLSF_INFO", "Wenn gesetzt, k&ouml;nnen sich Studenten f&uuml;r diesen Kurs nur &uuml;ber das HIS LSF anmelden.");
         $content->parse("HIS_LSF_PM");
     }
     if (!isset($values) || !isset($values["hislsf"])) {
         $content->setCurrentBlock("BLOCK_MAXSIZE");
         $content->setVariable("LABEL_MAXSIZE", gettext("Max number of participants"));
         $content->setVariable("LABEL_MAXSIZE_DSC", gettext("To limit the max number of participants for your course enter a number greater than 0. Leave this field blank or enter a '0' for no limitation."));
         if (isset($values["maxsize"])) {
             $content->setVariable("VALUE_MAXSIZE", h($values["maxsize"]));
         }
         $content->parse("BLOCK_MAXSIZE");
         $content->setCurrentBlock("BLOCK_ACCESS");
         $content->setVariable("PARTICIPANT_MANAGEMENT", gettext("Participant Management"));
     }
     $access = \koala_group_course::get_access_descriptions();
     $access_default = PERMISSION_COURSE_PUBLIC;
     if (is_array($access) && (!isset($values) || !isset($values["hislsf"]))) {
         $content->setCurrentBlock("BLOCK_ACCESS");
         foreach ($access as $key => $array) {
             if ($key != PERMISSION_COURSE_PAUL_SYNC && $key != PERMISSION_UNDEFINED || isset($values) && (int) $values["access"] == PERMISSION_UNDEFINED) {
                 $content->setCurrentBlock("ACCESS");
                 $content->setVariable("LABEL", $array["summary_short"] . ": " . $array["label"]);
                 $content->setVariable("VALUE", $key);
                 if (isset($values) && $key == (int) $values["access"] || empty($values) && $key == $access_default) {
                     $content->setVariable("CHECK", "checked=\"checked\"");
                 }
                 if ($key == PERMISSION_COURSE_PASSWORD) {
                     $content->setVariable("ONCHANGE", "onchange=\"document.getElementById('passworddiv').style.display='block'\"");
                     $content->setCurrentBlock("ACCESS_PASSWORD");
                     $content->setVariable("LABEL_PASSWORD", gettext("Password"));
                     if (!empty($values["password"])) {
                         $content->setVariable("VALUE_PASSWORD", $values["password"]);
                     }
                     if (isset($values["access"]) && $values["access"] == PERMISSION_COURSE_PASSWORD) {
                         $content->setVariable("PASSWORDDIV_DISPLAY", "block");
                     } elseif (!isset($values["access"]) && $access_default == PERMISSION_COURSE_PASSWORD) {
                         $content->setVariable("PASSWORDDIV_DISPLAY", "block");
                     } else {
                         $content->setVariable("PASSWORDDIV_DISPLAY", "none");
                     }
                     $content->parse("ACCESS_PASSWORD");
                 } else {
                     $content->setVariable("ONCHANGE", "onchange=\"document.getElementById('passworddiv').style.display='none'\"");
                 }
                 $content->parse("ACCESS");
             }
         }
         $content->parse("BLOCK_ACCESS");
     }
     // extensions:
     //$extensions = \lms_steam::get_extensionmanager()->get_extensions_by_class( 'koala_group_course' );
     $extensions = 0;
     /*if ( count( $extensions ) > 0 ) {
     			$content->setCurrentBlock( "BLOCK_EXTENSIONS" );
     			$content->setVariable( "LABEL_EXTENSIONS", gettext( "Extensions" ) );
     			$extension_list = array();
     			foreach ( $extensions as $extension ) {
     				if( $extension->get_requirements() === array() )
     				{
     					$extension_name = $extension->get_name();
     					$content->setCurrentBlock( "BLOCK_EXTENSION" );
     					$content->setVariable( "EXTENSION_ID", $extension_name );
     					$content->setVariable( "EXTENSION_NAME", $extension->get_display_name() );
     					$content->setVariable( "EXTENSION_DESC", $extension->get_display_description() );
     					$subextensions = \lms_steam::get_extensionmanager()->get_dependent_extensions($extension);
     					if( count( $subextensions ) > 0 )
     					{
     						$content->setCurrentBlock( "BLOCK_SUBEXTENSIONS" );
     						$content->setVariable( "LABEL_SUBEXTENSIONS", str_replace( "%EXTENSION", h($extension->get_display_name()), gettext( "The following sub-extensions are available for %EXTENSION" ) ));
     						foreach($subextensions as $subextension)
     						{
     							$subextension_name = $subextension->get_name();
     							$content->setCurrentBlock( "BLOCK_SUBEXTENSION" );
     							$content->setVariable( "PARENT_EXTENSION_ID", $extension_name );
     							$content->setVariable( "SUBEXTENSION_ID", $subextension_name );
     							$content->setVariable( "SUBEXTENSION_NAME", $subextension->get_display_name() );
     							$content->setVariable( "SUBEXTENSION_DESC", $subextension->get_display_description() );
     							$content->setVariable( "SUBEXTENSION_DISABLED", "disabled=\"disabled\"" );
     							$content->parse( "BLOCK_SUBEXTENSION" );
     							$extension_list[] = $subextension_name;
     						}
     						$content->parse( "BLOCK_SUBEXTENSIONS" );
     					}
     					$content->parse( "BLOCK_EXTENSION" );
     					$extension_list[] = $extension_name;
     				}
     			}
     			$content->setVariable( "VALUE_EXTENSIONS", implode( "/", $extension_list ) );
     			$content->parse( "BLOCK_EXTENSIONS" );
     		}*/
     $content->setVariable("LABEL_CREATE_COURSE", gettext("Create and finish"));
     $content->setVariable("LABEL_CREATE_ADD_ADMIN", gettext("Create and add further admins"));
     //$portal->set_page_main(
     //array( array( "link" => PATH_URL . SEMESTER_URL . "/" . $current_semester->get_name(). "/", "name" => h($current_semester->get_attribute( "OBJ_DESC" )) ), array( "link" => "", "name" => gettext( "Create new course" ) ) ),
     //$content->get()
     //);
     $frameResponseObject->setHeadline(array(array("link" => PATH_URL . "semester/index" . "/" . $current_semester->get_name() . "/", "name" => h($current_semester->get_attribute("OBJ_DESC"))), array("link" => "", "name" => gettext("Create new course"))));
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
Esempio n. 2
0
<?php

require_once "../etc/koala.conf.php";
if (!defined("PATH_TEMPLATES_UNITS_VILM")) {
    define("PATH_TEMPLATES_UNITS_VILM", PATH_EXTENSIONS . "units_vilm/templates/");
}
if (!isset($portal)) {
    $portal = lms_portal::get_instance();
    $portal->initialize(GUEST_NOT_ALLOWED);
}
$user = lms_steam::get_current_user();
$unitname = $unit->get_display_name();
if (!lms_steam::is_steam_admin($user) && !lms_steam::is_semester_admin($current_semester, $user) && !$course->is_admin($user)) {
    include "bad_link.php";
    exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST["id"] == $unit->get_id()) {
        try {
            $unit->delete();
            $owner = koala_object::get_koala_object(steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["owner"]));
            $backlink = $owner->get_url() . "units/";
        } catch (Exception $exception) {
            $problems = $exception->get_message();
        }
    }
    if (empty($problems)) {
        $_SESSION["confirmation"] = str_replace("%NAME", $unitname, gettext("The unit '%NAME' has been deleted."));
        header("Location: " . $backlink);
        exit;
    } else {
Esempio n. 3
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $path = $this->params;
     $user = \lms_steam::get_current_user();
     $content = \Semester::getInstance()->loadTemplate("courses_overview.template.html");
     $content->setVariable("HELP_TEXT", "<b>" . gettext('Notice') . ':</b> ' . gettext('You can easily find courses by using the filter. Just type in a part of the course\'s title, it\'s ID or the name of the tutor.'));
     $content->setVariable('LABEL_FILTER', gettext('Filter'));
     /**
      * Action Bar
      */
     $content->setCurrentBlock("BLOCK_ACTIONBAR");
     $isFiltered = false;
     $isEditMode = false;
     if (isset($path[0])) {
         if (\steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]) instanceof \steam_group) {
             $current_semester = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "courses." . $path[0]);
         } else {
             ExtensionMaster::getInstance()->send404Error();
         }
     } else {
         $current_semester = \lms_steam::get_current_semester();
     }
     $current_semester_name = $current_semester->get_name();
     if (isset($path[1]) && $path[1] == "booked") {
         $isFiltered = true;
     }
     if (isset($path[2]) && $path[2] == "edit") {
         $isEditMode = true;
     }
     if ($isFiltered) {
         if (ALL_COURSES) {
             $content->setCurrentBlock("BLOCK_ALL_COURSES");
             $content->setVariable("LABEL_MY_COURSES", gettext("All courses"));
             $content->setVariable("LINK_MY_COURSES", PATH_URL . "semester/index/" . $current_semester_name . "/all" . ($isEditMode ? "/edit" : ""));
             $content->parse("BLOCK_ALL_COURSES");
         }
     } else {
         if (YOUR_COURSES) {
             $content->setCurrentBlock("BLOCK_YOUR_COURSES");
             $content->setVariable("LABEL_MY_COURSES", gettext("My courses"));
             $content->setVariable("LINK_MY_COURSES", PATH_URL . "semester/index/" . $current_semester_name . "/booked" . ($isEditMode ? "/edit" : ""));
             $content->parse("BLOCK_YOUR_COURSES");
         }
     }
     if ($isEditMode) {
         $content->setCurrentBlock("BLOCK_EDIT_MODE");
         $content->setVariable("LABEL_EDIT_MODE", gettext("Disable edit mode"));
         $content->setVariable("LINK_EDIT_MODE", PATH_URL . "semester/index/" . $current_semester_name . ($isFiltered ? "/booked" : "/all"));
         $content->parse("BLOCK_EDIT_MODE");
     } else {
         $content->setCurrentBlock("BLOCK_EDIT_MODE");
         $content->setVariable("LABEL_EDIT_MODE", gettext("Enable edit mode"));
         $content->setVariable("LINK_EDIT_MODE", PATH_URL . "semester/index/" . $current_semester_name . ($isFiltered ? "/booked" : "/all") . "/edit");
         $content->parse("BLOCK_EDIT_MODE");
     }
     $is_steam_admin = \lms_steam::is_steam_admin($user);
     if ($is_steam_admin || \lms_steam::is_semester_admin($current_semester, $user)) {
         $content->setCurrentBlock("BLOCK_SEMESTER_ADMIN");
         if (ADD_COURSE) {
             $content->setCurrentBlock("BLOCK_ADD_COURSE");
             $content->setVariable("LINK_CREATE_COURSE", PATH_URL . "semester/addCourse" . "/" . $current_semester_name);
             $content->setVariable("LABEL_CREATE_COURSE", gettext("Create new course"));
             $content->parse("BLOCK_ADD_COURSE");
         }
         if (IMPORT_COURSE_FROM_PAUL) {
             $content->setCurrentBlock("BLOCK_IMPORT_COURSE_FROM_PAUL");
             $content->setVariable("LINK_CREATE_PAUL_COURSE", PATH_URL . "semester/importCourse" . "/" . $current_semester_name);
             $content->setVariable("LABEL_CREATE_PAUL_COURSE", gettext("Create new course via PAUL"));
             $content->parse("BLOCK_IMPORT_COURSE_FROM_PAUL");
         }
         if ($is_steam_admin) {
             $content->setCurrentBlock("BLOCK_SERVER_ADMIN");
             if (MANAGE_SEMESTER) {
                 $content->setCurrentBlock("BLOCK_MANAGE_SEMESTER");
                 $content->setVariable("LINK_MANAGE_SEMESTER", PATH_URL . "semester/manageSemester" . "/" . $current_semester_name);
                 $content->setVariable("LABEL_MANAGE_SEMESTER", gettext("Manage this semester"));
                 $content->parse("BLOCK_MANAGE_SEMESTER");
             }
             if (ADD_SEMESTER) {
                 $content->setCurrentBlock("BLOCK_ADD_SEMESTER");
                 $content->setVariable("LINK_CREATE_SEMESTER", PATH_URL . "semester/addSemester");
                 $content->setVariable("LABEL_CREATE_SEMESTER", gettext("Create new semester"));
                 $content->parse("BLOCK_ADD_SEMESTER");
             }
             $content->parse("BLOCK_SERVER_ADMIN");
         }
         $content->parse("BLOCK_SEMESTER_ADMIN");
     }
     $content->parse("BLOCK_ACTIONBAR");
     // AUS DEM SYSTEM AUSLESEN
     $cache = get_cache_function("ORGANIZATION", 600);
     $semesters = $cache->call("lms_steam::get_semesters");
     foreach ($semesters as $s) {
         $content->setCurrentBlock("BLOCK_TABS");
         if ($s["OBJ_NAME"] == $current_semester_name) {
             $content->setVariable("TAB_STATE", "tabOut");
             $content->setVariable("LINK_SEMESTER", $s["OBJ_NAME"]);
         } else {
             $content->setVariable("TAB_STATE", "tabIn");
             $filter_part = "";
             $content->setVariable("LINK_SEMESTER", "<a href=\"" . PATH_URL . "semester/index" . "/" . $s["OBJ_NAME"] . "/" . ($isFiltered ? "booked" : "all") . "\">" . $s["OBJ_NAME"] . "</a>");
         }
         $content->parse("BLOCK_TABS");
     }
     $courses = $isFiltered ? $cache->call("lms_steam::semester_get_courses", $current_semester->get_id(), $user->get_name()) : $cache->call("lms_steam::semester_get_courses", $current_semester->get_id());
     $no_courses = count($courses);
     if ($no_courses > 0) {
         $content->setCurrentBlock("BLOCK_COURSES_AVAILABLE");
         $content->setVariable("LABEL_ID", gettext("Course ID"));
         $content->setVariable("LABEL_NAME", gettext("Course Name"));
         $content->setVariable("LABEL_DESC", gettext("Information"));
         $content->setVariable("LABEL_TUTORS", gettext("Staff members"));
         $content->setVariable("LABEL_STUDENTS", gettext("Students"));
         $content->setVariable("LABEL_ACTION", gettext("Action"));
         $memberships = \lms_steam::semester_get_user_coursememberships($current_semester->get_id(), \lms_steam::get_current_user());
         foreach ($courses as $course) {
             $course_found = TRUE;
             /* THIS WAS ALREADY COMMENTED OUT!
                //Cannot be determined after performance optimization, so deleted courses remain in course list for CACHE_LIFETIME_STATIC (1 Hour)
                if ( !isset( $memberships[ $course["OBJ_ID"] ] ) ) {
                  error_log("courses_overview.php: Found deleted course in cache-data of semester=" . $current_semester->get_name() . " courseid=" . $course["OBJ_NAME"] ." description=" . $course["OBJ_DESC"] . " objectid=" . $course[ "OBJ_ID" ]);
                  $course_found = FALSE;
                }
                */
             if ($course_found) {
                 $is_subscribed = isset($memberships[$course["OBJ_ID"]]);
                 $content->setCurrentBlock("BLOCK_COURSE");
                 if (\koala_group_course::is_paul_course($course["COURSE_NUMBER"])) {
                     $label_course_id = $course["COURSE_NUMBER"];
                 } else {
                     $label_course_id = \koala_group_course::convert_course_id($course["OBJ_NAME"]);
                 }
                 $actions = "";
                 if ($isEditMode) {
                     $actions .= "<br><a href=\"" . PATH_URL . "course_delete.php?course=" . $course["OBJ_ID"] . "\">" . gettext("Delete course") . "</a>";
                     $actions .= "<br><a href=\"" . PATH_URL . "copy_weblog_wiki.php?course=" . $course["OBJ_ID"] . "\">" . gettext("Copy Weblog/Wiki") . "</a>";
                 }
                 $content->setVariable("VALUE_ID", h($label_course_id));
                 // TODO: Passt der Link?
                 $content->setVariable("COURSE_LINK", PATH_URL . SEMESTER_URL . "/" . h($current_semester->get_name()) . "/" . h($course["OBJ_NAME"]) . "/");
                 $content->setVariable("COURSE_NAME", h($course["OBJ_DESC"]));
                 $content->setVariable("COURSE_TUTORS", h($course["COURSE_TUTORS"]));
                 $content->setVariable("VALUE_STUDENTS", $course["COURSE_NO_PARTICIPANTS"] . (isset($course["COURSE_MAX_PARTICIPANTS"]) && $course["COURSE_MAX_PARTICIPANTS"] > 0 ? " / " . $course["COURSE_MAX_PARTICIPANTS"] : ""));
                 $content->setVariable("VALUE_COURSE_DESC", h($course["COURSE_SHORT_DSC"]));
                 if ($is_subscribed) {
                     if ($course["COURSE_HISLSF_ID"] > 0) {
                         $content->setVariable("COURSE_ACTION", "Kursabmeldung erfolgt ausschlie&szlig;&uuml;ber <b><a href=\"https://lsf.uni-paderborn.de/qisserver/rds?state=wsearchv&search=2&veranstaltung.veranstid=" . trim($course["COURSE_HISLSF_ID"]) . "\" target=\"_blank\">HIS-LSF</a></b>. Die Synchronisation mit koaLA kann bis zu einer Stunde dauern.");
                     } elseif ($course[KOALA_GROUP_ACCESS] == PERMISSION_COURSE_PAUL_SYNC) {
                         $content->setVariable("COURSE_ACTION", gettext("You are member.") . "<br />" . gettext("The participants for this course will be imported from the PAUL system as of 30.04.2009"));
                         $noop = gettext("The participant management for this course is imported from PAUL. To unsubscribe this course unsubscribe this course in PAUL. Your unsubscription will be synchronized with koaLA within one hour.");
                     } else {
                         $content->setVariable("COURSE_ACTION", "<a href=\"" . PATH_URL . "group_cancel.php?group=" . $course["OBJ_ID"] . "\">" . gettext("Resign") . "</a>" . $actions);
                     }
                 } else {
                     if ($course["COURSE_HISLSF_ID"] > 0) {
                         $content->setVariable("COURSE_ACTION", "Kursbuchung erfolgt ausschlie&szlig;lich &uuml;ber <b><a href=\"https://lsf.uni-paderborn.de/qisserver/rds?state=wsearchv&search=2&veranstaltung.veranstid=" . trim($course["COURSE_HISLSF_ID"]) . "\" target=\"_blank\">HIS-LSF</a></b>. Die Synchronisation mit koaLA kann bis zu einer Stunde dauern.");
                     } elseif ($course[KOALA_GROUP_ACCESS] == PERMISSION_COURSE_PAUL_SYNC) {
                         $content->setVariable("COURSE_ACTION", gettext("You are not member.") . "<br />" . gettext("The participants for this course will be imported from the PAUL system as of 30.04.2009"));
                         $noop = gettext("The participant management for this course is imported from PAUL. To subscribe this course subscribe this course in PAUL. Your subscription will be synchronized with koaLA within one hour.");
                     } elseif (isset($course["COURSE_MAX_PARTICIPANTS"]) && (int) $course["COURSE_MAX_PARTICIPANTS"] > 0 && (int) $course["COURSE_MAX_PARTICIPANTS"] <= (int) $course["COURSE_NO_PARTICIPANTS"]) {
                         $content->setVariable("COURSE_ACTION", gettext("Group is full"));
                     } else {
                         $content->setVariable("COURSE_ACTION", "<a href=\"" . PATH_URL . "group_subscribe.php?group=" . $course["OBJ_ID"] . "\">" . gettext("Sign on") . "</a>");
                     }
                 }
                 $content->parse("BLOCK_COURSE");
             }
         }
         $content->parse("BLOCK_COURSES_AVAILABLE");
     } else {
         $content->setCurrentBlock("BLOCK_NO_COURSE");
         $content->setVariable("NO_COURSE_TEXT", gettext("No courses available yet."));
         $content->parse("BLOCK_NO_COURSE");
     }
     //$headline = ( isset($_GET[ "filter" ]) && $_GET[ "filter" ] == "booked" ) ? gettext( "My courses in %SEMESTER" ) : gettext( "All courses in %SEMESTER" );
     //$portal->set_page_title( $current_semester->get_attribute( "OBJ_DESC" ));
     //$portal->set_page_main( str_replace( "%SEMESTER", $current_semester->get_attribute( "OBJ_DESC" ), $headline), $content->get(), "" );
     //$portal->show_html();
     $frameResponseObject->setTitle("Semester - " . $current_semester_name);
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
Esempio n. 4
0
         $content->parse("BLOCK_YOUR_COURSES");
     }
 }
 if ($isEditMode) {
     $content->setCurrentBlock("BLOCK_EDIT_MODE");
     $content->setVariable("LABEL_EDIT_MODE", gettext("Disable edit mode"));
     $content->setVariable("LINK_EDIT_MODE", PATH_URL . SEMESTER_URL . "/" . $current_semester->get_name() . ($isFiltered ? "/?" . $filter : "/"));
     $content->parse("BLOCK_EDIT_MODE");
 } else {
     $content->setCurrentBlock("BLOCK_EDIT_MODE");
     $content->setVariable("LABEL_EDIT_MODE", gettext("Enable edit mode"));
     $content->setVariable("LINK_EDIT_MODE", PATH_URL . SEMESTER_URL . "/" . $current_semester->get_name() . "/?mode=edit" . ($isFiltered ? "&" . $filter : ""));
     $content->parse("BLOCK_EDIT_MODE");
 }
 $is_steam_admin = lms_steam::is_steam_admin($user);
 if ($is_steam_admin || lms_steam::is_semester_admin($current_semester, $user)) {
     $content->setCurrentBlock("BLOCK_SEMESTER_ADMIN");
     if (ADD_COURSE) {
         $content->setCurrentBlock("BLOCK_ADD_COURSE");
         $content->setVariable("LINK_CREATE_COURSE", PATH_URL . SEMESTER_URL . "/" . $current_semester->get_name() . "/new/");
         $content->setVariable("LABEL_CREATE_COURSE", gettext("Create new course"));
         $content->parse("BLOCK_ADD_COURSE");
     }
     if (IMPORT_COURSE_FROM_PAUL) {
         $content->setCurrentBlock("BLOCK_IMPORT_COURSE_FROM_PAUL");
         $content->setVariable("LINK_CREATE_PAUL_COURSE", PATH_URL . SEMESTER_URL . "/" . $current_semester->get_name() . "/paul/");
         $content->setVariable("LABEL_CREATE_PAUL_COURSE", gettext("Create new course via PAUL"));
         $content->parse("BLOCK_IMPORT_COURSE_FROM_PAUL");
     }
     if ($is_steam_admin) {
         $content->setCurrentBlock("BLOCK_SERVER_ADMIN");
Esempio n. 5
0
<?php

include_once "../etc/koala.conf.php";
include_once PATH_LIB . "url_handling.inc.php";
include_once PATH_LIB . "format_handling.inc.php";
$portal = lms_portal::get_instance();
$portal->initialize(GUEST_NOT_ALLOWED);
$user = lms_steam::get_current_user();
$course = steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_GET["course"]);
$semester_name = $course->get_attribute("COURSE_SEMESTER");
$semester_object = steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "Courses." . $semester_name);
$admin_group = steam_factory::get_group($GLOBALS["STEAM"]->get_id(), "Admin");
$is_semester_admin = lms_steam::is_semester_admin($semester_object, $user);
//TODO: semester_admin check
//if ( !$admin_group->is_member( $user ) && !$is_semester_admin )
if (!is_object($admin_group) || !$admin_group->is_member($user)) {
    header("location:/");
    exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST["copy"]) {
        $weblogs_ids = $_POST["weblogs"];
        $wiki_ids = $_POST["wikis"];
        //TODO: Update Cache
        $_SESSION["confirmation"] = gettext("Copy complete.");
        header("Location: " . PATH_URL . "semester/" . $semester_name . "/?mode=edit");
        exit;
    }
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "copy_weblog_wiki.template.html");