| | |
| | | const fs = require("node:fs") |
| | | |
| | | const db = require("./lib/db") |
| | | const libIlias = require("lib/libIlias") |
| | | const libIlias = require("./lib/libIlias") |
| | | const settings = require("./settings") |
| | | const search = require("./lib/search.js") |
| | | |
| | |
| | | const sp = new URLSearchParams({ |
| | | command: "deleteUser", |
| | | obj_id, |
| | | dry : dry ? 1 : 0, |
| | | dry : dry ? "1" : "0", |
| | | }) |
| | | let url2 = `${url}?${sp.toString()}` |
| | | console.log("libIlias.deleteUser >>>", url2) |
| | |
| | | $method = $_SERVER['REQUEST_METHOD']; |
| | | $command = $_GET["command"]; |
| | | $obj_id = (int) $_GET["obj_id"]; |
| | | $dry = $_GET["dry"]; |
| | | $dry = $_GET["dry"]; # "0" = false, "1" = true |
| | | |
| | | $res = array( |
| | | "method" => $method, |
| | |
| | | |
| | | ############################### |
| | | |
| | | function deleteUser($obj_id, $dry = 0) |
| | | function deleteUser($obj_id, $dry) |
| | | { |
| | | $usr = ilObjectFactory::getInstanceByObjId($obj_id); |
| | | $msg = "deleted user {$usr->firstname} {$usr->lastname} ({$obj_id}) '{$dry}'"; |
| | | if ($dry == "1") { |
| | | $msg = "deleted user {$usr->firstname} {$usr->lastname} ({$obj_id})"; |
| | | if ($dry == "0") { |
| | | $usr->delete(); |
| | | return $msg; |
| | | } else { |
| | | $msg = $msg . " DRY"; |
| | | $msg = "DRY:: ".$msg; |
| | | return $msg; |
| | | } |
| | | } |
| | |
| | | const expect = require("chai").expect |
| | | |
| | | const settings = require("../settings") |
| | | const libIlias = require("../lib/libIlias") |
| | | |
| | |
| | | describe("the function deleteUser", function () { |
| | | |
| | | it("should delete a user", async function () { |
| | | const obj_id = 317 |
| | | const res = await libIlias.deleteUser(obj_id, false) |
| | | const obj_id = 324 |
| | | const res = await libIlias.deleteUser(obj_id, true) |
| | | console.log(res) |
| | | expect(res.method).to.equal("DELETE") |
| | | expect(res.command).to.equal("deleteUser") |
| | | expect(res.obj_id).to.equal(obj_id) |
| | | expect(res.status).to.equal("ok") |
| | | }) |
| | | |
| | | }) |