20 require_once
"user-del-helper.php";
21 define(
"TITLE_USER_DEL", _(
"Delete A User"));
23 use \Fossology\Lib\Auth\Auth;
31 function __construct()
33 $this->Name =
"user_del";
34 $this->Title = TITLE_USER_DEL;
35 $this->MenuList =
"Admin::Users::Delete";
37 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
39 parent::__construct();
51 $sql =
"SELECT * FROM users WHERE user_pk = '$UserId' LIMIT 1;";
52 $result = pg_query($PG_CONN, $sql);
54 $row = pg_fetch_assoc($result);
55 pg_free_result($result);
56 if (empty($row[
'user_name'])) {
57 $text = _(
"User does not exist.");
64 $sql =
"SELECT group_pk FROM groups WHERE group_name = '$row[user_name]' LIMIT 1;";
65 $result = pg_query($PG_CONN, $sql);
67 $GroupRow = pg_fetch_assoc($result);
68 pg_free_result($result);
71 $sql =
"DELETE FROM group_user_member WHERE user_fk = '$UserId'";
72 $result = pg_query($PG_CONN, $sql);
74 pg_free_result($result);
77 $sql =
"DELETE FROM users WHERE user_pk = '$UserId';";
78 $result = pg_query($PG_CONN, $sql);
80 pg_free_result($result);
86 $sql =
"SELECT * FROM users WHERE user_name = '$UserId' LIMIT 1;";
87 $result = pg_query($PG_CONN, $sql);
89 $rowCount = pg_num_rows($result);
90 pg_free_result($result);
92 $text = _(
"Failed to delete user.");
109 if (! empty($User)) {
111 $rc =
"Deletion not confirmed. Not deleted.";
113 $rc = deleteUser($User, $this->
dbManager);
117 $text = _(
"User deleted.");
118 $this->vars[
'message'] = $text;
120 $this->vars[
'message'] = $rc;
125 $currentUserId = Auth::getUserId();
126 $sql =
"SELECT user_pk,user_name,user_desc FROM users WHERE user_pk != '$currentUserId' AND user_pk != '1' ORDER BY user_name";
127 $result = pg_query($PG_CONN, $sql);
129 if (pg_num_rows($result) == 0) {
130 $V .= _(
"No users to delete.");
133 $V .= _(
"Deleting a user removes the user entry from the FOSSology system. The user's name, account information, and password will be <font color='red'>permanently</font> removed. (There is no 'undo' to this delete.)<P />\n");
134 $V .=
"<form name='formy' method='POST'>\n";
135 $V .= _(
"To delete a user, enter the following information:<P />\n");
137 $V .= _(
"<li>Select the user to delete.<br />");
138 $V .=
"<select name='userid' class='ui-render-select2'>\n";
139 while ($row = pg_fetch_assoc($result)) {
140 $V .=
"<option value='" . $row[
'user_pk'] .
"'>";
141 $V .= $row[
'user_name'];
146 $text = _(
"Confirm user deletion");
147 $V .=
"<P /><li>$text: <input type='checkbox' name='confirm' value='1'>";
151 $V .=
"<input type='submit' value='$text'>\n";
154 pg_free_result($result);
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
Delete($UserId)
Delete a user.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Output()
Generate the text for this plugin.
DeleteGroup($group_pk)
Delete a group.