The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delete Users SQL Logic
#1
Hello!

I'm using UserSpice for about a month now, making some changes (will post later in the "Modifications and Hackery") and I found something that I want to share with you guys.

The problem is if you delete an user, can happen that it won't delete the permission_matches/profile entries.

In the us_helpers.php we have a method for deletion of users, in the queries you find:
$query1 = $db->query("DELETE FROM users WHERE id = ?",array($id));
$query2 = $db->query("DELETE FROM user_permission_matches WHERE id = ?",array($id));
$query3 = $db->query("DELETE FROM profiles WHERE id = ?",array($id));

But, for the query2/query3 I think it should be "user_id", instead of just "id".

The version of UserSpice that I'm using is 4.1.2.
I liked a lot UserSpice and also learned a lot with the codes of it! Please keep up with this good work! Smile

PS: Sorry about my english, it's not my first language. Greetings from Brazil. o/

Regards,
Rukichirimoshi
  Reply
#2
Thank you so much! You are right. I have been meaning to take a look at that, and it slipped my mind. Your code looks great to me (so does your English). I will update our code.

I'm glad you're enjoying userspice and finding it helpful!
  Reply
#3
Thanks for answering me, @mudmin.

I also found the same problem in the "deletePermission" method (instead of "id", should be "permission_id").

Again, thank you! Smile
  Reply
#4
I have implemented those fixes. Thanks for those.
  Reply
#5
i know its a little old but was those fixes done for the 4.1.3 release ? also i noticed when deleting a user we get the success message but the rest of the page fails to load, so after success but before add new user form its choking somewhere, ive looked hard but cant see where the issue is, has anyone notice this issue ?

you also notice that the dropdown menu no longer works when it happens
  Reply
#6
Hmm. I've recorded this in the bug tracker. I'm hoping to push out a few bug fixes by early next week. I'll be looking for a solution. If you happen to find one in the mean time, PLEASE let me know!
  Reply
#7
awesome, i think I've got it working, may not be the best way but seems to work, in admin_users.php find
`if($validation->passed()) {
$form_valid = TRUE;
try {

$fields=array(
'username' => Input::get('username'),
'fname' => Input::get('fname'),
'lname' => Input::get('lname'),
'email' => Input::get('email'),
'password' => password_hash(Input::get('password'), PASSWORD_BCRYPT, array('cost' => 12)),
'permissions' => 1,
'account_owner' => 1,
'stripe_cust_id' => '',
'join_date' => $join_date,
'company' => Input::get('company'),
'email_verified' => 1,
'active' => 1,
'vericode' => 111111,
);
$db->insert('users',$fields);
$theNewId=$db->lastId();
$addNewPermission = array('user_id' => $theNewId, 'permission_id' => $perm);
$db->insert('user_permission_matches',$addNewPermission);

} catch (Exception $e) {
die($e->getMessage());
}

}else{
$val_err = display_errors($validation->errors());
}`

notice above yours won't have the else statement, so add that into your file, now further down the page find the add new users form add replace:

if (!$form_valid && Input::exists()){
echo display_errors($validation->errors());
}`

with:

Code:
echo $val_err;

this should fix it, see below:

[Image: Screen%7B3bc1fe685386cc4c3ab89a3f76566d893....33.02.png]
  Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)