20 require_once __DIR__ .
"/../../lib/php/common-db.php";
21 require_once __DIR__ .
"/../../lib/php/common-perms.php";
29 function deleteUser($UserId, $dbManager)
34 $userSelectStatement = __METHOD__ .
".getUser";
35 $dbManager->prepare($userSelectStatement,
36 "SELECT * FROM users WHERE user_pk = $1 LIMIT 1;");
38 $selectGroupStatement = __METHOD__ .
".getGroup";
39 $dbManager->prepare($selectGroupStatement,
40 "SELECT group_pk FROM groups WHERE group_name = $1 LIMIT 1;");
42 $deleteGroupUserStatement = __METHOD__ .
".deleteGroupUser";
43 $dbManager->prepare($deleteGroupUserStatement,
44 "DELETE FROM group_user_member WHERE user_fk = $1;");
46 $deleteUserStatement = __METHOD__ .
".deleteUser";
47 $dbManager->prepare($deleteUserStatement,
48 "DELETE FROM users WHERE user_pk = $1;");
50 $userCheckStatement = __METHOD__ .
".getUserbyName";
51 $dbManager->prepare($userCheckStatement,
52 "SELECT count(*) AS cnt FROM users WHERE user_name = $1 LIMIT 1;");
55 $result = $dbManager->execute($userSelectStatement, [$UserId]);
56 $row = $dbManager->fetchArray($result);
57 $dbManager->freeResult($result);
58 if (empty($row[
'user_name'])) {
59 $text = _(
"User does not exist.");
66 $result = $dbManager->execute($selectGroupStatement, [$row[
'user_name']]);
67 $GroupRow = $dbManager->fetchArray($result);
68 $dbManager->freeResult($result);
71 $dbManager->freeResult($dbManager->execute($deleteGroupUserStatement, [$UserId]));
74 $dbManager->freeResult($dbManager->execute($deleteUserStatement, [$UserId]));
80 $result = $dbManager->execute($userCheckStatement, [$UserId]);
81 $rowCount = count($dbManager->fetchArray($result)[
'cnt']);
82 $dbManager->freeResult($result);
84 $text = _(
"Failed to delete user.");
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DeleteGroup($group_pk)
Delete a group.