Closed (outdated)
Project:
Privatemsg
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Sep 2011 at 16:10 UTC
Updated:
6 Dec 2023 at 13:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ovi.indrei commentedI can confirm the same error when a user with 'allow disabling privatemsg' permissions (e.g. admin) tries to disable private messages (repeatedly) for another user that doesn't has this specific permission.
To reproduce the error:
Attached is a patch for the 7.x-1.x-dev. It's my first one, hopefully it's a good one. Please review it and let me know. Thanks.
Comment #3
ovi.indrei commentedIt looks like my first patch didn't work out. I used WinMerge to create it :).
The current patch is done using git, hopefully this will make it.
Comment #5
berdirAs you can see in the tests, that permission check is necessary. The problem is that if you remove that permission from a role and users currently have privatemsg disabled, they have no way of turning it on again. If that check results in the error you described, we need to find another solution to fix it.
Comment #6
internetdevels commentedThis patch fixes the issue for me.
Comment #8
bogeyman commentedHi, I think we need another permission for disabling other users' private message option.
Comment #9
bogeyman commentedHi, I think we need another permission for disabling other users' private message option. We also need to modify the permission checking in privatemsg_is_disabled() function.
Sorry, I uploaded the wrong file format in my comment above.
Comment #10
bogeyman commentedHere is a new patch from me. I add the new checking condition. If the current user is not the same as the edited user, the checkbox for disabling the private message will be only appeared if the current user has permission for disabling other users' private message.
Comment #11
berdirDo we really need a specific permission for this? We could also just use the normal administration permission...
Comment #12
bogeyman commentedYes, you're right. We could use administer privatemsg settings for that. Here is the new patch
Comment #13
bogeyman commentedHi, this is another patch from me. I move the permission for checking if user allowed to disable other users' private message into a function. This function will be called when the update user form is altered (in privatemsg_form_alter) and when the user gets updated (in privatemsg_user_update).
Sorry, for changing the patch repeatedly in a day :).
Comment #14
berdirTo make this consistent, we also need to pass $account to the new user_access() call.
.. if *the* user...
And should have @param and @return documentation, see other non-hook functions for examples.
I think just privatemsg_allow_disable() is enough, the "is" is not necessary.
This shouldn't be necessary. Even for an anonymous user (for which this function should not be called, as you can't edit that one), $account->uid is set and is 0.
So this can be simplified.
Comment #15
bogeyman commentedThe first and second user_access call are different matter. The first for is checking if the edited user account has 'allow disabling privatemsg' permission and the second is for checking if current user has 'administer privatemsg settings' permission. So if the edited user account and the current user are different (eg. admin edit the user1 which has no 'administer privatemsg settings' permission) and we pass the $account to user_access, it will give the wrong result.
Comment #16
berdirRight, but it means that the function returns different results depending on the current user. Which is a problem, because it means the admin can change the setting for another user as long as he wants, it will not actually change for the user if we does not have the permission to change it himself as well.
Which means that there are only two ways this can work.
- Do not allow admins to change it if the user would not be able to change it. Probably easier to fix.
- Allow admins to disable it for users even if they can't do it themself, e.g. as a way to ban users without their knowing. This is arguably a new feature and would be easier to implement in 7.x-2.x because we will need to store this as a separate setting.
Comment #17
bogeyman commentedI understand your point of view. So, for the fastest solution to solve this issue, I choose the first option. The admin can only disable the users' private message if only the users are able to enable it again.
Here is my new patch.
Comment #18
ptmkenny commentedPotentially related issue (Could be dupe): http://drupal.org/node/1087514
Comment #19
ptmkenny commentedA related issue was fixed:
https://drupal.org/node/1605190
Please confirm that this issue is still active; the patches look almost identical to me.
Comment #20
ptmkenny commentedSince there has been no activity for a month, I'm closing.
Comment #21
a.milkovskyIssue is still present. Fix #6 works for me. But I don't know what is with tests there.
I fixed privatemsg_is_disabled() instead.
user_access('allow disabling privatemsg', $account) was always executed for the checked account and not for current account.
Please check the patch
Comment #22
fagoafaics, this is done by the patch and was the intention of the code so far. Fix solves the PDO error also.
Comment #23
ivnish