Exemple #1
0
 /**
  * set connection
  *
  * sets connection with seminar
  * @access public
  * @param string $seminar_id seminar-id
  * @return boolean successful
  */
 function setConnection($seminar_id)
 {
     $this->is_connected = true;
     //      echo "$this->id, $this->module_type, $this->cms_type";
     return ObjectConnections::setConnection($seminar_id, $this->id, $this->module_type, $this->cms_type);
 }
 /**
  * create course
  *
  * creates new ilias course
  * @access public
  * @param string $seminar_id seminar-id
  * @return boolean successful
  */
 function createCourse($seminar_id)
 {
     global $messages, $SessSemName, $DEFAULT_LANGUAGE, $ELEARNING_INTERFACE_MODULES;
     $crs_id = ObjectConnections::getConnectionModuleId($seminar_id, "crs", $this->cms_type);
     $this->soap_client->setCachingStatus(false);
     $this->soap_client->clearCache();
     if ($crs_id == false) {
         $seminar = Seminar::getInstance($seminar_id);
         $home_institute = Institute::find($seminar->getInstitutId());
         if ($home_institute) {
             $ref_id = ObjectConnections::getConnectionModuleId($home_institute->getId(), "cat", $this->cms_type);
         }
         if ($ref_id < 1) {
             // Kategorie für Heimateinrichtung anlegen
             $object_data["title"] = sprintf("%s", $home_institute->name);
             $object_data["description"] = sprintf(_("Hier befinden sich die Veranstaltungsdaten zur Stud.IP-Einrichtung \"%s\"."), $home_institute->name);
             $object_data["type"] = "cat";
             $object_data["owner"] = $this->soap_client->LookupUser($ELEARNING_INTERFACE_MODULES[$this->cms_type]["soap_data"]["username"]);
             $ref_id = $this->soap_client->addObject($object_data, $this->main_category_node_id);
             ObjectConnections::setConnection($home_institute->getId(), $ref_id, "cat", $this->cms_type);
         }
         if ($ref_id < 1) {
             $ref_id = $this->main_category_node_id;
         }
         // Kurs anlegen
         $lang_array = explode("_", $DEFAULT_LANGUAGE);
         $course_data["language"] = $lang_array[0];
         $course_data["title"] = "Stud.IP-Kurs " . $seminar->getName();
         $course_data["description"] = "";
         $crs_id = $this->soap_client->addCourse($course_data, $ref_id);
         if ($crs_id == false) {
             $messages["error"] .= _("Zuordnungs-Fehler: Kurs konnte nicht angelegt werden.");
             return false;
         }
         ObjectConnections::setConnection($seminar_id, $crs_id, "crs", $this->cms_type);
         // Rollen zuordnen
         $this->permissions->CheckUserPermissions($crs_id);
     }
     return $crs_id;
 }
Exemple #3
0
 /**
  * Displays a page.
  */
 public function edit_action($id = null)
 {
     global $connected_cms, $current_module;
     if (!$this->rechte) {
         throw new AccessDeniedException(_('Keine Berechtigung zum Bearbeiten der Lernmodul-Verknüpfungen.'));
     }
     Navigation::activateItem('/course/elearning/edit');
     $GLOBALS['view'] = 'edit';
     // ggf. neuen Ilias4-Kurs anlegen
     if (Request::submitted('create_course') and $this->rechte) {
         ELearningUtils::loadClass($this->cms_select);
         if (method_exists($connected_cms[$this->cms_select], "createCourse")) {
             if ($connected_cms[$this->cms_select]->createCourse($this->seminar_id)) {
                 PageLayout::postMessage(MessageBox::info(_('Kurs wurde angelegt.')));
             }
         }
     }
     // ggf. bestehenden Ilias4-Kurs zuordnen
     if (Request::submitted('connect_course')) {
         if (ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select) and $GLOBALS['perm']->have_studip_perm("dozent", Request::option("connect_course_sem_id"))) {
             ObjectConnections::setConnection($this->seminar_id, ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select), "crs", $this->cms_select);
             PageLayout::postMessage(MessageBox::info(_('Zuordnung wurde gespeichert.')));
             ELearningUtils::loadClass($this->cms_select);
             if (method_exists($connected_cms[$this->cms_select], "updateConnections")) {
                 $connected_cms[$this->cms_select]->updateConnections(ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select));
             }
         }
     }
     // Zugeordnete Ilias-Kurse ermitteln und ggf. aktualisieren
     $this->course_output = ELearningUtils::getIliasCourses($this->seminar_id);
     if ($this->new_account_cms == "") {
         if ($this->module_system_type != "") {
             $user_crs_role = $connected_cms[$this->module_system_type]->crs_roles[$GLOBALS['auth']->auth["perm"]];
             ELearningUtils::loadClass($this->module_system_type);
         }
         if (Request::submitted('remove')) {
             $connected_cms[$this->module_system_type]->newContentModule($this->module_id, $this->module_type, true);
             if ($connected_cms[$this->module_system_type]->content_module[$this->module_id]->unsetConnection($this->seminar_id, $this->module_id, $this->module_type, $this->module_system_type)) {
                 PageLayout::postMessage(MessageBox::info(_('Die Zuordnung wurde entfernt.')));
             }
             unset($connected_cms[$this->module_system_type]->content_module[$this->module_id]);
         } elseif (Request::submitted('add')) {
             $connected_cms[$this->module_system_type]->newContentModule($this->module_id, $this->module_type, true);
             if ($connected_cms[$this->module_system_type]->content_module[$this->module_id]->setConnection($this->seminar_id)) {
                 PageLayout::postMessage(MessageBox::info(_('Die Zuordnung wurde gespeichert.')));
             }
             unset($connected_cms[$this->module_system_type]->content_module[$this->module_id]);
         }
         if ($this->search_key != "") {
             ELearningUtils::loadClass($this->cms_select);
             if (strlen(trim($this->search_key)) > 2) {
                 $searchresult_content_modules = $connected_cms[$this->cms_select]->searchContentModules($this->search_key);
             } else {
                 PageLayout::postMessage(MessageBox::error(_('Jeder Suchbegriff muss mindestens 3 Zeichen lang sein!')));
             }
         }
     }
     //Instanz mit den Zuordnungen von Content-Modulen zur Veranstaltung
     $object_connections = new ObjectConnections($this->seminar_id);
     $connected_modules = $object_connections->getConnections();
     $this->module_count = 0;
     $content_modules_list = array();
     $user_modules_list = array();
     $search_modules_list = array();
     if ($object_connections->isConnected()) {
         $caching_active = true;
         foreach ($connected_modules as $key => $connection) {
             if (ELearningUtils::isCMSActive($connection["cms"])) {
                 ELearningUtils::loadClass($connection["cms"]);
                 $connected_cms[$connection["cms"]]->newContentModule($connection["id"], $connection["type"], true);
                 $connected_modules[$key]['title'] = $connected_cms[$connection["cms"]]->content_module[$connection["id"]]->getTitle();
                 $title_tmp[$key] = str_replace(array('ä', 'ö', 'ü', 'ß'), array('ae', 'oe', 'ue', 'ss'), strtolower($connected_modules[$key]['title']));
                 $type_tmp[$key] = array_search($connection['type'], array_keys($GLOBALS['ELEARNING_INTERFACE_MODULES'][$connection["cms"]]['types']));
                 $class_tmp[$key] = $GLOBALS['ELEARNING_INTERFACE_MODULES'][$connection["cms"]]["CLASS_PREFIX"];
             }
         }
         array_multisort($class_tmp, SORT_ASC, $type_tmp, SORT_ASC, $title_tmp, SORT_ASC, $connected_modules);
         foreach ($connected_modules as $index => $connection) {
             $current_module = $connection["id"];
             if ($this->module_count == 0) {
                 $content_modules_list[$index]['show_header'] = true;
             }
             $this->module_count++;
             $this->module_system_count[$connection["cms"]]++;
             if ($this->open_all != "") {
                 $_SESSION['elearning_open_close'][$connected_cms[$connection["cms"]]->content_module[$connection["id"]]->getReferenceString()] = true;
             } elseif ($this->close_all != "") {
                 $_SESSION['elearning_open_close'][$connected_cms[$connection["cms"]]->content_module[$connection["id"]]->getReferenceString()] = false;
             }
             $content_modules_list[$index]['module'] = $connected_cms[$connection["cms"]]->content_module[$connection["id"]]->view->showAdmin();
         }
     }
     if ($this->module_count == 0 and $this->new_account_cms == "") {
         if ($_SESSION['SessSemName']['class'] == 'inst') {
             PageLayout::postMessage(MessageBox::info(_('Momentan sind dieser Einrichtung keine Lernmodule zugeordnet.')));
         } else {
             PageLayout::postMessage(MessageBox::info(_('Momentan sind dieser Veranstaltung keine Lernmodule zugeordnet.')));
         }
     }
     $this->caching_active = false;
     if (isset($GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_select]["name"])) {
         ELearningUtils::loadClass($this->cms_select);
         $user_content_modules = $connected_cms[$this->cms_select]->getUserContentModules();
         if (!($user_content_modules == false)) {
             foreach ($user_content_modules as $key => $connection) {
                 // show only those modules which are not already connected to the seminar
                 if (is_object($connected_cms[$this->cms_select]->content_module[$connection["ref_id"]])) {
                     continue;
                 }
                 $connected_cms[$this->cms_select]->setContentModule($connection, false);
                 $connected_cms[$this->cms_select]->content_module[$current_module]->view->showAdmin();
                 $user_modules_list[$key]['module'] = $connected_cms[$this->cms_select]->content_module[$current_module]->view->showAdmin();
             }
         }
         if (!$connected_cms[$this->cms_select]->isAuthNecessary() || $connected_cms[$this->cms_select]->user->isConnected()) {
             $this->show_search = true;
         }
         if (!($searchresult_content_modules == false)) {
             foreach ($searchresult_content_modules as $key => $connection) {
                 // show only those modules which are not already connected to the seminar
                 if (is_object($connected_cms[$this->cms_select]->content_module[$connection["ref_id"]])) {
                     continue;
                 }
                 $connected_cms[$this->cms_select]->setContentModule($connection, false);
                 $search_modules_list[$key]['module'] = $connected_cms[$this->cms_select]->content_module[$current_module]->view->showAdmin();
             }
         }
         // ILIAS 4: Leeren Kurs anlegen oder Kurse von anderen Veranstaltungen zuordnen
         if (method_exists($connected_cms[$this->cms_select], "updateConnections") and !$this->module_system_count[$this->cms_select] and !ObjectConnections::getConnectionModuleId($this->seminar_id, "crs", $this->cms_select)) {
             $show_ilias_empty_course = true;
             if ($GLOBALS['perm']->have_perm('root')) {
                 $query = "SELECT DISTINCT object_id, module_id, Name\n                                  FROM object_contentmodules\n                                  LEFT JOIN seminare ON (object_id = Seminar_id)\n                                  WHERE module_type = 'crs' AND system_type = ?";
             } else {
                 $query = "SELECT DISTINCT object_id, module_id, Name\n                                  FROM object_contentmodules\n                                  LEFT JOIN seminare ON (object_id = Seminar_id)\n                                  LEFT JOIN seminar_user USING (Seminar_id)\n                                  WHERE module_type = 'crs' AND system_type = ? AND seminar_user.status = 'dozent'";
             }
             $statement = DBManager::get()->prepare($query);
             $statement->execute(array($this->cms_select));
             while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
                 if ($GLOBALS['perm']->have_studip_perm('dozent', $row['object_id'])) {
                     $existing_courses[$row['object_id']] = my_substr($row['Name'], 0, 60) . " " . sprintf(_("(Kurs-ID %s)"), $row['module_id']);
                 }
             }
         } elseif (method_exists($connected_cms[$this->cms_select], "updateConnections") and count($connected_cms[$this->cms_select]->types['webr'])) {
             $this->show_ilias_link_info = true;
             $crs_data = ObjectConnections::getConnectionModuleId($this->seminar_id, "crs", $this->cms_select);
         }
     }
     // Cachen der SOAP-Daten
     if (is_array($connected_cms)) {
         foreach ($connected_cms as $system) {
             $system->terminate();
         }
     }
     $widget = new ActionsWidget();
     if (count($this->course_output['courses'])) {
         $widget->addLink(_('Zuordnungen aktualisieren'), URLHelper::getURL('?view=edit&cms_select=' . $this->cms_select . '&update=1'), Icon::create('refresh', 'clickable'));
     }
     $this->sidebar->addWidget($widget);
     $this->new_account = $this->new_account_cms;
     $this->is_inst = $_SESSION['SessSemName']['class'] == 'inst';
     if ($this->cms_select) {
         $this->cms_name = $connected_cms[$this->cms_select]->getName();
         $this->cms_logo = $connected_cms[$this->cms_select]->getLogo();
         $this->user_modules = $user_modules_list;
         $this->search_modules = $search_modules_list;
         $this->existing_courses = $existing_courses;
         $this->show_ilias_empty_course = $show_ilias_empty_course;
     }
     $this->content_modules = $content_modules_list;
 }
 /**
  * set connection
  *
  * sets connection with seminar
  * @access public
  * @param string $seminar_id seminar-id
  * @return boolean successful
  */
 function setConnection($seminar_id)
 {
     global $connected_cms, $messages, $SessSemName, $DEFAULT_LANGUAGE;
     $write_permission = Request::option("write_permission");
     $write_permission_autor = Request::option("write_permission_autor");
     $crs_id = ObjectConnections::getConnectionModuleId($seminar_id, "crs", $this->cms_type);
     //      echo "SET?".$this->cms_type;
     $connected_cms[$this->cms_type]->soap_client->setCachingStatus(false);
     $connected_cms[$this->cms_type]->soap_client->clearCache();
     // Check, ob Kurs in ILIAS gelöscht wurde
     if ($crs_id != false and $connected_cms[$this->cms_type]->soap_client->getObjectByReference($crs_id) == false) {
         ObjectConnections::unsetConnection($seminar_id, $crs_id, "crs", $this->cms_type);
         //          echo "deleted: ".ObjectConnections::getConnectionModuleId($seminar_id, "crs", $this->cms_type);
         //          echo "Der zugeordnete ILIAS-Kurs (ID $crs_id) existiert nicht mehr. Ein neuer Kurs wird angelegt.";
         $messages["info"] .= _("Der zugeordnete ILIAS-Kurs (ID {$crs_id}) existiert nicht mehr. Ein neuer Kurs wird angelegt.") . "<br>";
         $crs_id = false;
     }
     if ($crs_id == false) {
         $lang_array = explode("_", $DEFAULT_LANGUAGE);
         $course_data["language"] = $lang_array[0];
         $course_data["title"] = "Stud.IP-Kurs " . $SessSemName[0];
         $course_data["description"] = "";
         $ref_id = $connected_cms[$this->cms_type]->main_category_node_id;
         $crs_id = $connected_cms[$this->cms_type]->soap_client->addCourse($course_data, $ref_id);
         if ($crs_id == false) {
             $messages["error"] .= _("Zuordnungs-Fehler: Kurs konnte nicht angelegt werden.");
             return false;
         }
         ObjectConnections::setConnection($seminar_id, $crs_id, "crs", $this->cms_type);
         // Rollen zuordnen
         $connected_cms[$this->cms_type]->permissions->CheckUserPermissions($crs_id);
         //          $messages["info"] .= "Neue Kurs-ID: $crs_id. <br>";
     }
     $ref_id = $this->getId();
     $ref_id = $connected_cms[$this->cms_type]->soap_client->addReference($this->id, $crs_id);
     $local_roles = $connected_cms[$this->cms_type]->soap_client->getLocalRoles($crs_id);
     $member_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ));
     $admin_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ, OPERATION_WRITE));
     foreach ($local_roles as $key => $role_data) {
         // check only if local role is il_crs_member, -tutor or -admin
         if (strpos($role_data["title"], "il_crs_") === 0) {
             if (strpos($role_data["title"], 'il_crs_member') === 0) {
                 $operations = $write_permission_autor ? $admin_operations : $member_operations;
             } else {
                 if (strpos($role_data["title"], 'il_crs_tutor') === 0) {
                     $operations = $write_permission_autor || $write_permission ? $admin_operations : $member_operations;
                 } else {
                     continue;
                 }
             }
             $connected_cms[$this->cms_type]->soap_client->revokePermissions($role_data["obj_id"], $ref_id);
             $connected_cms[$this->cms_type]->soap_client->grantPermissions($operations, $role_data["obj_id"], $ref_id);
         }
     }
     if ($ref_id) {
         $this->setId($ref_id);
         return parent::setConnection($seminar_id);
     } else {
         $messages["error"] .= _("Die Zuordnung konnte nicht gespeichert werden.");
     }
     return false;
 }