/** * 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; $write_permission = Request::option("write_permission"); $crs_id = ObjectConnections::getConnectionModuleId($seminar_id, "crs", $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); $messages["info"] .= _("Der zugeordnete ILIAS-Kurs (ID {$crs_id}) existiert nicht mehr. Ein neuer Kurs wird angelegt.") . "<br>"; $crs_id = false; } $crs_id == $connected_cms[$this->cms_type]->createCourse($seminar_id); if ($crs_id == false) { return false; } $ref_id = $this->getId(); if (Request::get("copy_object") == "1") { $connected_cms[$this->cms_type]->soap_client->user_type = 'user'; $ref_id = $connected_cms[$this->cms_type]->soap_client->copyObject($this->id, $crs_id); $connected_cms[$this->cms_type]->soap_client->user_type = 'admin'; } else { $ref_id = $connected_cms[$this->cms_type]->soap_client->addReference($this->id, $crs_id); } if (!$ref_id) { $messages["error"] .= _("Zuordnungs-Fehler: Objekt konnte nicht angelegt werden."); return false; } $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, OPERATION_DELETE)); $admin_operations_no_delete = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ, OPERATION_WRITE)); $admin_operations_readonly = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ, OPERATION_DELETE)); 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_no_delete : $member_operations; } elseif (strpos($role_data["title"], 'il_crs_tutor') === 0) { $operations = $write_permission == "tutor" || $write_permission == "autor" ? $admin_operations : $admin_operations_readonly; } elseif (strpos($role_data["title"], 'il_crs_admin') === 0) { $operations = $write_permission == "dozent" || $write_permission == "tutor" || $write_permission == "autor" ? $admin_operations : $admin_operations_readonly; } 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 ContentModule::setConnection($seminar_id); } else { $messages["error"] .= _("Die Zuordnung konnte nicht gespeichert werden."); } return false; }
/** * unset connection * * unsets connection with seminar * @access public * @param string $seminar_id seminar-id * @return boolean successful */ function unsetConnection($seminar_id) { $this->is_connected = false; return ObjectConnections::unsetConnection($seminar_id, $this->id, $this->module_type, $this->cms_type); }
/** * check connected modules and update connections * * checks if there are modules in the course that are not connected to the seminar * @access public * @param string $course_id course-id * @return boolean successful */ function updateConnections($course_id) { global $connected_cms, $messages, $SessSemName, $object_connections; $db = DBManager::get(); $result = $this->soap_client->getObjectByReference($course_id); if ($result) { $course_path = $this->soap_client->getRawPath($course_id) . '_' . $result["ref_id"]; } $this->soap_client->setCachingStatus(false); // fetch childs $result = $this->getChilds($course_id); if (is_array($result)) { $check = $db->prepare("SELECT 1 FROM object_contentmodules WHERE object_id = ? AND module_id = ? AND system_type = ? AND module_type = ?"); $found = array(); $added = 0; $deleted = 0; $messages["info"] .= "<b>" . sprintf(_("Aktualisierung der Zuordnungen zum System \"%s\":"), $this->getName()) . "</b><br>"; foreach ($result as $ref_id => $data) { $check->execute(array($SessSemName[1], $ref_id, $this->cms_type, $data["type"])); if (!$check->fetch()) { $messages["info"] .= sprintf(_("Zuordnung zur Lerneinheit \"%s\" wurde hinzugefügt."), $data["title"]) . "<br>"; ObjectConnections::setConnection($SessSemName[1], $ref_id, $data["type"], $this->cms_type); $added++; } $found[] = $ref_id . '_' . $data["type"]; } $to_delete = $db->prepare("SELECT module_id,module_type FROM object_contentmodules WHERE module_type <> 'crs' AND object_id = ? AND system_type = ? AND CONCAT_WS('_', module_id,module_type) NOT IN (?)"); $to_delete->execute(array($SessSemName[1], $this->cms_type, count($found) ? $found : array(''))); while ($row = $to_delete->fetch(PDO::FETCH_ASSOC)) { ObjectConnections::unsetConnection($SessSemName[1], $row["module_id"], $row["module_type"], $this->cms_type); $deleted++; $messages["info"] .= sprintf(_("Zuordnung zu \"%s\" wurde entfernt."), $row["module_id"] . '_' . $row["module_type"]) . "<br>"; } if ($added + $deleted < 1) { $messages["info"] .= _("Die Zuordnungen sind bereits auf dem aktuellen Stand.") . "<br>"; } } ELearningUtils::bench("update connections"); }
/** * 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; }