9 require_once
"user-del-helper.php";
10 define(
"TITLE_USER_DEL", _(
"Delete A User"));
12 use \Fossology\Lib\Auth\Auth;
22 $this->Name =
"user_del";
23 $this->Title = TITLE_USER_DEL;
24 $this->MenuList =
"Admin::Users::Delete";
26 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
28 parent::__construct();
40 $sql =
"SELECT * FROM users WHERE user_pk = '$UserId' LIMIT 1;";
43 $row = pg_fetch_assoc($result);
44 pg_free_result($result);
45 if (empty($row[
'user_name'])) {
46 $text = _(
"User does not exist.");
53 $sql =
"SELECT group_pk FROM groups WHERE group_name = '$row[user_name]' LIMIT 1;";
56 $GroupRow = pg_fetch_assoc($result);
57 pg_free_result($result);
60 $sql =
"DELETE FROM group_user_member WHERE user_fk = '$UserId'";
63 pg_free_result($result);
66 $sql =
"DELETE FROM users WHERE user_pk = '$UserId';";
69 pg_free_result($result);
75 $sql =
"SELECT * FROM users WHERE user_name = '$UserId' LIMIT 1;";
78 $rowCount = pg_num_rows($result);
79 pg_free_result($result);
81 $text = _(
"Failed to delete user.");
100 $rc =
"Deletion not confirmed. Not deleted.";
102 $rc = deleteUser($User, $this->
dbManager);
106 $text = _(
"User deleted.");
107 $this->vars[
'message'] = $text;
109 $this->vars[
'message'] = $rc;
114 $currentUserId = Auth::getUserId();
115 $sql =
"SELECT user_pk,user_name,user_desc FROM users WHERE user_pk != '$currentUserId' AND user_pk != '1' ORDER BY user_name";
118 if (pg_num_rows($result) == 0) {
119 $V .= _(
"No users to delete.");
122 $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");
123 $V .=
"<form name='formy' method='POST'>\n";
124 $V .= _(
"To delete a user, enter the following information:<P />\n");
126 $V .= _(
"<li>Select the user to delete.<br />");
127 $V .=
"<select name='userid' class='ui-render-select2'>\n";
128 while ($row = pg_fetch_assoc($result)) {
129 $V .=
"<option value='" . $row[
'user_pk'] .
"'>";
130 $V .= $row[
'user_name'];
135 $text = _(
"Confirm user deletion");
136 $V .=
"<P /><li>$text: <input type='checkbox' name='confirm' value='1'>";
140 $V .=
"<input type='submit' value='$text'>\n";
143 pg_free_result($result);
This is the Plugin class. All plugins should:
Delete($UserId)
Delete a user.
__construct()
base constructor. Most plugins will just use this
Output()
Generate the text for this plugin.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
DeleteGroup($group_pk)
Delete a group.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
fo_dbManager * dbManager
fo_dbManager object