Closed (fixed)
Project:
Profile 2
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Jun 2016 at 16:08 UTC
Updated:
15 Jan 2019 at 17:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sandip27 commentedComment #3
sandip27 commentedHi manoloka, Please find attached patch for feature to Provide Delete own profile to user.
@joachim, I guess this is one of most useful feature that needed to be in module. Please check and review and merge the patch attached. It would be great to see this feature in action.
Thanks
Comment #4
joachim commentedI don't really understand the use case for deleting a profile. It doesn't really match the intended architecture of the module.
Comment #5
manoloka commentedit may be not a usual case ... but right now I have the need to delete some users profile without wanting to get rid of the user account .... in the other hand administrators should always have the oportunity to delete any piece of content
Thanks
Comment #6
manoloka commentedsandip27 - does this patch lets you delete only your own profile?
what about an administrator deleting any profile?
thanks
Comment #7
manoloka commentedwhat I'd like is to have administrators the chance to delete any profile?
I guess that should have a set of permissions too
Comment #8
manoloka commentedjoachim - a use case for deleting a profile ... can be that as profiles can hold "personal information" you are obliged (probably by law, I don't know where you live but we sure are in the EU) to give users the opportunity to delete their own personal information.
Thanks
Comment #9
sandip27 commented@joachim, Yes, this patch lets you delete only your own profile unless otherwise set in permissions. admin on the other hand will always be able to delete all the user's profile information as set by permissions.
Thanks
Comment #10
manoloka commented@Sandip27, I've applied the patch and I don't see how to delete the profiles ... I was expecting a "Delete" button as usually found in other nodes. Not in my own profile (this case user 1) nor any other profile.
Can you explain what is the procedure on how to delete profiles on a per user basis?
I do see the 2 new permissions
Thanks
Comment #11
manoloka commented@Sandip27 Hi realize now that this patch will only work if you have chosen "Provide a separate page for editing profiles" option, which is not my case. Is there a way to put it in the standard user form?
That said ... I've been able to delete what I wanted to by chosing "Provide a separate page for editing profiles" deleting the couple of users profiles I wanted to and going back to my original settings ... however I think it'd be nice to have this feature ready to work for both options.
Thanks
Comment #12
sandip27 commented@manoloka, Please check attached updated patch. This should cover both the options for this feature.
@joachim, would really love to see this feature in module. Please review and merge this patch. Let me know if any queries.
Thanks
Comment #13
joachim commented> Please review and merge this patch. Let me know if any queries.
Reviewed, but there are a whole load of problems with this patch... please check your patch at least complies with Drupal coding standards before you invoke a maintainer ;)
Coddled else.
Why iterate over all the types? This is the form for a particular profile entity, so you should only be considering its type.
(And this makes no sense anyway: you're repeatedly clobbering the form element in the loop.)
Include the profile type name in this. And perhaps make it clear to users that this is NOT deleting their account!
Coddled.
Get this out of the profile, not the arg().
Move this out of the condition, and only set $confirm_question in the condition.
Again, you're clobbering an item in a loop. Makes no sense.
Is there a %profile menu loader we can use here?
Move this to a .inc file.
Coddled.
Not the right way to use this. For starters, AFAIK you return drupal_access_denied().
And anyway, use a menu access callback!!
Coddled!
Pointless. If you have no access to the form, you can't ever get here.
No need to check_plain() here. Types are machine names.
Why all this? Get the profile you want from the form state!
Spaces around . operator.
???!
Comment #14
sandip27 commented@joachim,
Please find attached revised patch as per suggestions.
Make a note, "file" does not apply to other callbacks (only page callback) and since our page callback is 'drupal_get_form', so seems not matching the ideal conditions to move it to .inc file.
For menu access callback, however tried every possible way, but strangely its not applying as it should so couldn't use.
Let me know if any further advice to fine tune the patch, otherwise, good to go ahead and merge.
@manoloka, Please use attached updated patch. This one is after taking care of suggestions from joachim.
Thanks
Comment #15
joachim commentedI don't mind which form you use for this, but be consistent ;)
Avoid abbreviations in variables. $delete_button_label will do.
Uncoddle please.
Can we have more detail here?
How would $profile->uid be empty? What are you doing in that case?
Can you explain the problem?
Why create it only to delete it?
You're not checking the permission here.
Use the label, not the machine name.
Missing terminal newline.
Still LOTS of coddled elses in this patch!! :(
Comment #16
sandip27 commented@joachim,
Your reviews are covered and below are updates for the same.
01. Done. Removed the second usage.
02. Done. I think, using "str" is kinda self explanatory that it is string type variable. Seems not needed. Updated the variable name.
03. Done.
04. "more detail" as in ? Please explain.
05. Done. Thought to be more precise, but again, seems not needed. Updated the code.
06. No matter what I write in "access callback" and "access arguments", it always returns "Access denied" even for super admin.
07. To ensure, that even if user hits a URL directly through browser then he won't get error in case of profile not already created.
08. Well, permission is already checked in form_alter so no need to check twice.
09. Done.
10. Done.
Please check and let me know if any further work needed.
Thanks
Comment #17
joachim commentedNot been done:
- Move this to a .inc file.
- Is there a %profile menu loader we can use here?
Could you check the other things I've mentioned in my 2 previous reviews?
> 04. "more detail" as in ? Please explain.
As I said in my first review, I think this needs to explain more to the user.
I think this is because you're inheriting the access callback from a parent menu item. Try declaring it explicitly.
Change this path to fit in with the scheme of the rest of the module.
Comment #18
sandip27 commentedSandip: "file" does not apply to other callbacks (only page callback) and since our page callback is 'drupal_get_form', so seems not matching the ideal conditions to move it to .inc file.
Sandip: As far as I know, we dont have so can not.
Sandip: "Are you sure you want to delete your own $profile->type profile ?" Line itself speaks for it. Give me exact words you want it to be displayed otherwise seems correct to me.
Sandip: If declared it explicitly, I would need to set 'access callback' => 'profile2_profile2_access' and for this function, it needs profile object as second parameter, which is not available in hook_menu. So it doesn't work for 'administrator' user to whom every profile should be available to delete.
Sandip: Well, had to set this path so that I can pass both uid as well as profile type to function for further access checking. If you think of any other path, which still can pass uid and profile type, then sure, please share it with me and will implement it.
Thanks
Comment #19
joachim commented> Sandip: "file" does not apply to other callbacks (only page callback) and since our page callback is 'drupal_get_form', so seems not matching the ideal conditions to move it to .inc file.
It's completely fine to put form callbacks in an .inc file like this. Look at the admin settings form in most modules.
> - Is there a %profile menu loader we can use here?
> Sandip: As far as I know, we dont have so can not.
I think it's fine to move this into profile module.
> Sandip: If declared it explicitly, I would need to set 'access callback' => 'profile2_profile2_access' and for this function, it needs profile object as second parameter, which is not available in hook_menu. So it doesn't work for 'administrator' user to whom every profile should be available to delete.
Should be profile2_access(). Don't call hook implementations directly. Should work once you use the menu loader from profile2_page. And also, writing a new menu access callback would still be better than having to return denied in the form builder!
> If you think of any other path, which still can pass uid and profile type, then sure, please share it with me and will implement it.
I would say follow the same pattern as profile2_page. Which looks like user/UID/profile-TYPE/delete
Comment #20
sandip27 commentedHello joachim,
Please find attached patch for review.
Sandip: Done
Sandip: Done
Sandip: Done
Sandip: Done
Thanks
Comment #21
sandip27 commented@joachim, any comments on uploaded patch and its review ? If everything is fine, would love to see the same merged and committed.
Thanks and appreciate your prompt response.
Comment #22
jantoine commented@sandip27
I noticed that the delete profile button exists when no profile exists (i.e. creating a new profile for an existing user).
Comment #23
jantoine commented@sandip27,
I also noticed there isn't a 'delete any TYPE profile' permission. I think this should be added for administration purposes and to match the permissions already provided.
Comment #24
sandip27 commented@jantoine, thanks for the comments.
1. Well, the delete button exists in order to match its current status. If you check the default module by joachim, its behaving the same ways. So its good to not deviate from existing functionality hence is the button.
2. Again, this patch is more of like providing the delete button to profile and not to manage the permissions etc. So not handling it in this one. Sure, will take care of it once this patch gets merged.
Thanks and again, appreciate your comments.
Sandip
Comment #25
sandip27 commented@joachim, have spent lots efforts and time on this enhancements. Would really love to see it in action. Since, its been over a month now, so Can you please take it further ahead and let me know if and when can we see this change merged and live ?
Thanks and appreciate your efforts on the same.
Comment #26
joachim commentedYou're not using the menu loader in your menu item.
Comment #27
sandip27 commented@joachim, Sorry, my bad ! Got skipped somehow. Fixed the same and here's updated patch. Please do review and if everything is fine, would love to see it merged.
Thanks again !!
Comment #28
sandip27 commentedCan any other maintainer of module review and merge this please ? Its been really long and would really appreciate if anybody could help me achieve this.
Thanks
Comment #29
sandip27 commented@joachim, OR Any maintainers, it's been 4 months or so for the patch submission. Really not possible to review it ? Awaiting for the response.
Thanks
Comment #30
sandip27 commented@joachim, still no word on merging this patch. :(
Thought, by this time, we would have already done it. It would be really great to see it in action.
Thanks.
Comment #31
rickj commentedThis all seems to work, and is compatible with 7.x-1.4.
Not everyone will want it (I don't on my sites), but by default the permission is not enabled so the Delete button doesn't appear, which is fine.
Can anyone else comment, and move it to RTBC?
Comment #32
jelo commentedWould this support a delete action for rules or strictly only the delete button on page?
Comment #33
rickj commentedThere was one mis-feature in this patch, in that it showed a Delete button when creating a new profile, This didn't happen in the original administrator-delete in Profile2-page. I've corrected this, see attached patch. I've also changed the text "Delete your profile" to "Delete this profile". Where a user has multiple profiles the former could be confusing, and imply deleting all profiles.
Confirmed working with 7.x-1.4.
Comment #34
rickj commentedComment #36
rickj commentedComment #38
jcisio commentedI think this patch requires the profile2_page module (is it really necessary?), and admin can't delete his own profile from what I see in the patch.
Comment #39
rickj commented@jcisio
It doesn't depend on profile2_page, the patch changes both versions of the profile edit form - the one in the main module and the one in the profile2_page module.
However, I can see that there is a slight hole in the logic, in that a user with administer-profiles permission still needs delete-own-profile permission to be able to delete their own.
I'll aim to fix that in a future release.
Thanks for your sharp observation!
Comment #40
rickj commented