/** * 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; }
/** * 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; }